/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI_SIFACT;
import AccesoDatosAvanzado.AD_Proveedor;
import AccesoDatosSimple.cProveedor;
import GUI_Busquedas.Frm_busq_proveedor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import sifact.conexion.cConexion;
/**
 *
 * @author Cyber Huevadictos
 */
public class Frm_Proveedor extends javax.swing.JFrame {
    private String txtnulos = "Los Campos Vacios son:\n";

    /**
     * Creates new form Frm_Proveedor
     */
    public Frm_Proveedor() {
        setDefaultLookAndFeelDecorated(true);
        this.addFocusListener(null);
        initComponents();
    }
 //funcion para limpiar los campos

    private void CamposClean() {
        jTextFieldCodigo.setText(null);
        jTextFieldEmpresa.setText(null);
        jTextFieldRepresentante.setText(null);
        jTextFieldCargo.setText(null);
        jTextAreaDireccion.setText(null);
        jTextFieldCiudad.setText(null);
        jTextFieldTlfno1.setText(null);
        jTextFieldTlfno2.setText(null);
        jTextFieldTlfno3.setText(null);        
    }
//funcion para bloquear campos cuando es Insercion

    private void CamposInsert() {
        //texto
        jTextFieldEmpresa.setEnabled(true);
        jTextFieldRepresentante.setEnabled(true);
        jTextFieldCargo.setEnabled(true);
        jTextAreaDireccion.setEnabled(true);
        jTextFieldCiudad.setEnabled(true);
        jTextFieldTlfno1.setEnabled(true);
        jTextFieldTlfno2.setEnabled(true);
        jTextFieldTlfno3.setEnabled(true);
        //botones
        jButtonBuscar.setEnabled(false);
        jButtonAceptar.setEnabled(true);
    }
//funcion para bloquear campos cuando es Actualizacion

    private void CamposUpdate() {
        //texto
        jTextFieldEmpresa.setEnabled(false);
        jTextFieldRepresentante.setEnabled(true);
        jTextFieldCargo.setEnabled(true);
        jTextAreaDireccion.setEnabled(true);
        jTextFieldCiudad.setEnabled(true);
        jTextFieldTlfno1.setEnabled(true);
        jTextFieldTlfno2.setEnabled(true);
        jTextFieldTlfno3.setEnabled(true);
        //botones
        jButtonBuscar.setEnabled(true);
        jButtonAceptar.setEnabled(false);
    }
//funcion para bloquear campos cuando es Eliminacion

    private void CamposDelete() {
        //texto
        jTextFieldEmpresa.setEnabled(false);
        jTextFieldRepresentante.setEnabled(false);
        jTextFieldCargo.setEnabled(false);
        jTextAreaDireccion.setEnabled(false);
        jTextFieldCiudad.setEnabled(false);
        jTextFieldTlfno1.setEnabled(false);
        jTextFieldTlfno2.setEnabled(false);
        jTextFieldTlfno3.setEnabled(false);        
        //botones
        jButtonBuscar.setEnabled(true);
        jButtonAceptar.setEnabled(false);
    }
//funcion que me permite verificar los campos nulos del formulario

    private boolean CamposNulos() {
        boolean band = false;

        if (jTextFieldEmpresa.getText().trim().equals("")) {
            txtnulos = txtnulos + "EMPRESA\n";
            band = true;
        }
        if (jTextFieldRepresentante.getText().trim().toUpperCase().equals("")) {
            txtnulos = txtnulos + "REPRESENTANTE\n";
            band = true;
        }
        if (jTextFieldCargo.getText().trim().toUpperCase().equals("")) {
            txtnulos = txtnulos + "CARGO\n";
            band = true;
        }
        if (jTextAreaDireccion.getText().trim().equals("")) {
            txtnulos = txtnulos + "DIRECCION\n";
            band = true;
        }
        if (jTextFieldTlfno1.getText().trim().equals("")) {
            txtnulos = txtnulos + "TELEFONO 1\n";
            band = true;
        }

        return band;
    }
//Set de los datos establecidos para el cliente

    private void DatosFormulario(cProveedor obj) {
//        obj.setNumIDCliente(Integer.parseInt(jTextFieldCodigo.getText().toString()));
        obj.setTxtNomEmpresa(jTextFieldEmpresa.getText().toUpperCase());
        obj.setTxtNomContacto(jTextFieldRepresentante.getText().toUpperCase());
        obj.setTxtCargoContacto(jTextFieldCargo.getText().toUpperCase());
        obj.setTxtDireccion(jTextAreaDireccion.getText().toUpperCase());
        obj.setTxtCiudad(jTextFieldCiudad.getText().toUpperCase());
        obj.setTxtNumTlfno1(jTextFieldTlfno1.getText());
        obj.setTxtNumTlfno2(jTextFieldTlfno2.getText());
        obj.setTxtNumTlfno3(jTextFieldTlfno3.getText());
    }
//Asigno los datos devueltos en una busqueda    

    private void DatosFormularioBusqueda(String obj) throws Exception {
        String[] tupla = new String[12];
        tupla = AD_Proveedor.BuscarEmpresa(obj);

        jTextFieldCodigo.setText(tupla[0]);
        jTextFieldEmpresa.setText(tupla[1]);
        jTextFieldRepresentante.setText(tupla[2]);
        jTextFieldCargo.setText(tupla[3]);
        jTextAreaDireccion.setText(tupla[4]);
        jTextFieldCiudad.setText(tupla[5]);
        jTextFieldTlfno1.setText(tupla[6]);
        jTextFieldTlfno2.setText(tupla[7]);
        jTextFieldTlfno3.setText(tupla[8]);
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupProveedor = new javax.swing.ButtonGroup();
        jPanelOpciones = new javax.swing.JPanel();
        jRadioButtonInsert = new javax.swing.JRadioButton();
        jRadioButtonUpdate = new javax.swing.JRadioButton();
        jRadioButtonDelete = new javax.swing.JRadioButton();
        jButtonBuscar = new javax.swing.JButton();
        jPanelBotones = new javax.swing.JPanel();
        jButtonAceptar = new javax.swing.JButton();
        jButtonCancelar = new javax.swing.JButton();
        jTabbedPaneDatos = new javax.swing.JTabbedPane();
        jPanelDatos = new javax.swing.JPanel();
        jLabelCodigo = new javax.swing.JLabel();
        jTextFieldCodigo = new javax.swing.JTextField();
        jLabelEmpresa = new javax.swing.JLabel();
        jLabelRepresentante = new javax.swing.JLabel();
        jLabelCargo = new javax.swing.JLabel();
        jLabelTlfno1 = new javax.swing.JLabel();
        jLabelTlfno2 = new javax.swing.JLabel();
        jTextFieldEmpresa = new javax.swing.JTextField();
        jTextFieldRepresentante = new javax.swing.JTextField();
        jTextFieldCargo = new javax.swing.JTextField();
        jTextFieldTlfno1 = new javax.swing.JTextField();
        jLabelEjmTlfno = new javax.swing.JLabel();
        jLabelTlfno3 = new javax.swing.JLabel();
        jTextFieldTlfno2 = new javax.swing.JTextField();
        jTextFieldTlfno3 = new javax.swing.JTextField();
        jLabelDireccion = new javax.swing.JLabel();
        jScrollPaneDireccion = new javax.swing.JScrollPane();
        jTextAreaDireccion = new javax.swing.JTextArea();
        jLabelCiudad = new javax.swing.JLabel();
        jTextFieldCiudad = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("DATOS DEL PROVEEDOR");

        jPanelOpciones.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPCIONES DEL PROVEEDOR", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 18))); // NOI18N

        buttonGroupProveedor.add(jRadioButtonInsert);
        jRadioButtonInsert.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonInsert.setText("AGREGAR");
        jRadioButtonInsert.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonInsertMouseClicked(evt);
            }
        });

        buttonGroupProveedor.add(jRadioButtonUpdate);
        jRadioButtonUpdate.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonUpdate.setText("MODIFICAR");
        jRadioButtonUpdate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonUpdateMouseClicked(evt);
            }
        });

        buttonGroupProveedor.add(jRadioButtonDelete);
        jRadioButtonDelete.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonDelete.setText("ELIMINAR");
        jRadioButtonDelete.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonDeleteMouseClicked(evt);
            }
        });

        jButtonBuscar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16Nuvola_search_person.png"))); // NOI18N
        jButtonBuscar.setText("BUSCAR");
        jButtonBuscar.setEnabled(false);
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelOpcionesLayout = new javax.swing.GroupLayout(jPanelOpciones);
        jPanelOpciones.setLayout(jPanelOpcionesLayout);
        jPanelOpcionesLayout.setHorizontalGroup(
            jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonBuscar)
                    .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                        .addComponent(jRadioButtonInsert)
                        .addGap(77, 77, 77)
                        .addComponent(jRadioButtonUpdate)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE)
                .addComponent(jRadioButtonDelete)
                .addContainerGap())
        );
        jPanelOpcionesLayout.setVerticalGroup(
            jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonInsert)
                    .addComponent(jRadioButtonUpdate)
                    .addComponent(jRadioButtonDelete))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonBuscar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelBotones.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButtonAceptar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16px-Crystal_Clear_action_apply.png"))); // NOI18N
        jButtonAceptar.setText("ACEPTAR");
        jButtonAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAceptarActionPerformed(evt);
            }
        });

        jButtonCancelar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16px-Crystal_Clear_action_button_cancel.png"))); // NOI18N
        jButtonCancelar.setText("CANCELAR");
        jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelBotonesLayout = new javax.swing.GroupLayout(jPanelBotones);
        jPanelBotones.setLayout(jPanelBotonesLayout);
        jPanelBotonesLayout.setHorizontalGroup(
            jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                .addComponent(jButtonCancelar)
                .addContainerGap())
        );
        jPanelBotonesLayout.setVerticalGroup(
            jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonAceptar)
                    .addComponent(jButtonCancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jPanelDatos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabelCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelCodigo.setText("CODIGO:");

        jTextFieldCodigo.setEditable(false);
        jTextFieldCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabelEmpresa.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelEmpresa.setText("EMPRESA:");

        jLabelRepresentante.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelRepresentante.setText("REPRESENTANTE:");

        jLabelCargo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelCargo.setText("CARGO:");

        jLabelTlfno1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelTlfno1.setText("TELEFONO 1:");

        jLabelTlfno2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelTlfno2.setText("TELEFONO 2:");

        jTextFieldEmpresa.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldEmpresa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldEmpresaKeyTyped(evt);
            }
        });

        jTextFieldRepresentante.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldRepresentante.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextFieldRepresentante.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldRepresentanteKeyTyped(evt);
            }
        });

        jTextFieldCargo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldCargo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldCargoKeyTyped(evt);
            }
        });

        jTextFieldTlfno1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldTlfno1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTlfno1KeyTyped(evt);
            }
        });

        jLabelEjmTlfno.setText("Ejm: 095632145");

        jLabelTlfno3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelTlfno3.setText("TELEFONO 3:");

        jTextFieldTlfno2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldTlfno2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTlfno2KeyTyped(evt);
            }
        });

        jTextFieldTlfno3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldTlfno3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTlfno3KeyTyped(evt);
            }
        });

        jLabelDireccion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelDireccion.setText("DIRECCION:");

        jTextAreaDireccion.setColumns(20);
        jTextAreaDireccion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextAreaDireccion.setRows(5);
        jScrollPaneDireccion.setViewportView(jTextAreaDireccion);

        jLabelCiudad.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelCiudad.setText("CIUDAD:");

        jTextFieldCiudad.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldCiudad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldCiudadKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanelDatosLayout = new javax.swing.GroupLayout(jPanelDatos);
        jPanelDatos.setLayout(jPanelDatosLayout);
        jPanelDatosLayout.setHorizontalGroup(
            jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDatosLayout.createSequentialGroup()
                        .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelCodigo)
                            .addComponent(jLabelEmpresa)
                            .addComponent(jLabelRepresentante)
                            .addComponent(jLabelCargo)
                            .addComponent(jLabelCiudad))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jTextFieldCiudad)
                                .addComponent(jTextFieldCargo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldRepresentante, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelDatosLayout.createSequentialGroup()
                                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldTlfno3, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldTlfno1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldTlfno2, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabelEjmTlfno))
                            .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 11, Short.MAX_VALUE))
                    .addGroup(jPanelDatosLayout.createSequentialGroup()
                        .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelDatosLayout.createSequentialGroup()
                                .addComponent(jLabelDireccion)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jScrollPaneDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelDatosLayout.createSequentialGroup()
                                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelTlfno1)
                                    .addComponent(jLabelTlfno2)
                                    .addComponent(jLabelTlfno3))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addContainerGap())))
        );
        jPanelDatosLayout.setVerticalGroup(
            jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCodigo)
                    .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelEmpresa)
                    .addComponent(jTextFieldEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelRepresentante)
                    .addComponent(jTextFieldRepresentante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCargo)
                    .addComponent(jTextFieldCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPaneDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelDatosLayout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(jLabelDireccion)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCiudad))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTlfno1)
                    .addComponent(jTextFieldTlfno1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEjmTlfno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTlfno2)
                    .addComponent(jTextFieldTlfno2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelTlfno3)
                    .addComponent(jTextFieldTlfno3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.addTab("DATOS DEL PROVEEDOR", jPanelDatos);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanelOpciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(5, 5, 5))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTabbedPaneDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanelBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(73, 73, 73))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelOpciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jTabbedPaneDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 408, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jRadioButtonInsertMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonInsertMouseClicked
        // TODO add your handling code here:
        CamposInsert();
        CamposClean();
        int e;
        try {
            e = AD_Proveedor.GetId();
            e += 1;
            if (e >= 0) {
                jTextFieldCodigo.setText(Integer.toString(e));
            } else {
                JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL OBTENER CODIGO", JOptionPane.ERROR_MESSAGE);
            }
            cConexion.cerrar();
        } catch (Exception ex) {
            Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jRadioButtonInsertMouseClicked

    private void jRadioButtonUpdateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonUpdateMouseClicked
        // TODO add your handling code here:
        CamposUpdate();
        CamposClean();
    }//GEN-LAST:event_jRadioButtonUpdateMouseClicked

    private void jRadioButtonDeleteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonDeleteMouseClicked
        // TODO add your handling code here:
        CamposDelete();
        CamposClean();
    }//GEN-LAST:event_jRadioButtonDeleteMouseClicked

    private void jButtonBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarActionPerformed
        // TODO add your handling code here:
        if (jRadioButtonUpdate.isSelected() == true || jRadioButtonDelete.isSelected() == true) {
            String objcadena = "";
            Frm_busq_proveedor.setDefaultLookAndFeelDecorated(true);
            Frm_busq_proveedor obj;
            try {
                obj = new Frm_busq_proveedor(null, true, objcadena);
                obj.setVisible(true);
                if (!obj.getObjcadena().equals("")) {
                    DatosFormularioBusqueda(obj.getObjcadena());
                }
                cConexion.cerrar();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + ex, "ERROR AL PASAR EL DATO", JOptionPane.ERROR_MESSAGE);
            }
            jButtonAceptar.setEnabled(true);
        }
    }//GEN-LAST:event_jButtonBuscarActionPerformed

    private void jButtonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptarActionPerformed

        //codigo para realizar las diferentes tareas Insert,Update,Delete
        Exception e;
        if (CamposNulos() == true) {//verifico que campo se encuentra vacio y advierto
            JOptionPane.showMessageDialog(null, txtnulos, "Campos Vacios", JOptionPane.INFORMATION_MESSAGE);
            txtnulos = "Los Campos Vacios son:\n";
        } else {//Inicio la Insercion
            if (jRadioButtonInsert.isSelected() == true) {
                cProveedor obj = new cProveedor();
                DatosFormulario(obj);
                try {
                    e = AD_Proveedor.Insertar(obj);
                    if (e == null) {
                        JOptionPane.showMessageDialog(null, "Los DATOS ha sido ingresado correctamente", "INSERTAR", JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL INSERTAR", JOptionPane.ERROR_MESSAGE);
                    }
                    dispose();
                    cConexion.cerrar();
                } catch (Exception ex) {
                    Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                }
            }//Terminamos con la Insercion
            else {//Inicio de Actualizacion
                if (jRadioButtonUpdate.isSelected() == true) {
                    cProveedor obj = new cProveedor();
                    DatosFormulario(obj);
                    try {

                        e = AD_Proveedor.Actualizar(obj);
                        if (e == null) {
                            JOptionPane.showMessageDialog(null, "Los DATOS se han actualizado correctamente", "MODIFICAR", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL MODIFICAR", JOptionPane.ERROR_MESSAGE);
                        }
                        dispose();
                        cConexion.cerrar();
                    } catch (Exception ex) {
                        Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }//terminanos con la Actualizacion
                else {//Iniciamos la Eliminacion

                    cProveedor obj = new cProveedor();
                    DatosFormulario(obj);
                    try {

                        e = AD_Proveedor.Eliminar(obj.getTxtNomEmpresa());
                        if (e == null) {
                            JOptionPane.showMessageDialog(null, "Los DATOS se han Eliminado correctamente", "ELIMINAR", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL ELIMINAR", JOptionPane.ERROR_MESSAGE);
                        }
                        dispose();
                        cConexion.cerrar();
                    } catch (Exception ex) {
                        Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }//Terminamos la Eliminacion
            }
        }
    }//GEN-LAST:event_jButtonAceptarActionPerformed

    private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed
        try {
            // TODO add your handling code here:
            dispose();
            cConexion.cerrar();
        } catch (Exception ex) {
            Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonCancelarActionPerformed

    private void jTextFieldEmpresaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldEmpresaKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= 'A' && t <= 'Z') || (t == ' ') || (t == 'Ñ') || (t == 'é') || (t == 'í') || (t == 'ó') || (t == 'ú') || (t == 'á') || (t == 'ñ') || ((t >= 'a' && t <= 'z'))) || jTextFieldEmpresa.getText().length() > 50) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldEmpresaKeyTyped

    private void jTextFieldRepresentanteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldRepresentanteKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= 'A' && t <= 'Z') || (t == ' ') || (t == 'Ñ') || (t == 'é') || (t == 'í') || (t == 'ó') || (t == 'ú') || (t == 'á') || (t == 'ñ') || ((t >= 'a' && t <= 'z'))) || jTextFieldRepresentante.getText().length() > 50) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldRepresentanteKeyTyped

    private void jTextFieldCargoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCargoKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= 'A' && t <= 'Z') || (t == ' ') || (t == 'Ñ') || (t == 'é') || (t == 'í') || (t == 'ó') || (t == 'ú') || (t == 'á') || (t == 'ñ') || ((t >= 'a' && t <= 'z'))) || jTextFieldCargo.getText().length() > 50) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldCargoKeyTyped

    private void jTextFieldTlfno1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTlfno1KeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldTlfno1.getText().length() > 8) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldTlfno1KeyTyped

    private void jTextFieldTlfno2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTlfno2KeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldTlfno2.getText().length() > 8) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldTlfno2KeyTyped

    private void jTextFieldTlfno3KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTlfno3KeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldTlfno3.getText().length() > 8) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldTlfno3KeyTyped

    private void jTextFieldCiudadKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCiudadKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= 'A' && t <= 'Z') || (t == ' ') || (t == 'Ñ') || (t == 'é') || (t == 'í') || (t == 'ó') || (t == 'ú') || (t == 'á') || (t == 'ñ') || ((t >= 'a' && t <= 'z'))) || jTextFieldCiudad.getText().length() > 50) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldCiudadKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Frm_Proveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frm_Proveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frm_Proveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frm_Proveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Frm_Proveedor().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupProveedor;
    private javax.swing.JButton jButtonAceptar;
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JLabel jLabelCargo;
    private javax.swing.JLabel jLabelCiudad;
    private javax.swing.JLabel jLabelCodigo;
    private javax.swing.JLabel jLabelDireccion;
    private javax.swing.JLabel jLabelEjmTlfno;
    private javax.swing.JLabel jLabelEmpresa;
    private javax.swing.JLabel jLabelRepresentante;
    private javax.swing.JLabel jLabelTlfno1;
    private javax.swing.JLabel jLabelTlfno2;
    private javax.swing.JLabel jLabelTlfno3;
    private javax.swing.JPanel jPanelBotones;
    private javax.swing.JPanel jPanelDatos;
    private javax.swing.JPanel jPanelOpciones;
    private javax.swing.JRadioButton jRadioButtonDelete;
    private javax.swing.JRadioButton jRadioButtonInsert;
    private javax.swing.JRadioButton jRadioButtonUpdate;
    private javax.swing.JScrollPane jScrollPaneDireccion;
    private javax.swing.JTabbedPane jTabbedPaneDatos;
    private javax.swing.JTextArea jTextAreaDireccion;
    private javax.swing.JTextField jTextFieldCargo;
    private javax.swing.JTextField jTextFieldCiudad;
    private javax.swing.JTextField jTextFieldCodigo;
    private javax.swing.JTextField jTextFieldEmpresa;
    private javax.swing.JTextField jTextFieldRepresentante;
    private javax.swing.JTextField jTextFieldTlfno1;
    private javax.swing.JTextField jTextFieldTlfno2;
    private javax.swing.JTextField jTextFieldTlfno3;
    // End of variables declaration//GEN-END:variables
}
